package com.fms.controller;

import com.fms.result.ResultData;
import com.fms.dto.MenuDto;
import com.fms.entity.Menu;
import com.fms.service.MenuService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("menu")
@RequiredArgsConstructor
public class MenuController {
    private final MenuService menuService;
    @GetMapping("/getMenus")
    //获取所有菜单
    public ResultData getMenus() {
        List<Menu> menus = menuService.getMenus();
        return ResultData.success(menus);
    }
    @GetMapping("/getMenuOption/{username}")
    //获取激活菜单
    public ResultData getMenuOption(@PathVariable("username") String username) {
        List<MenuDto> list = menuService.getMenuOption(username);
        return ResultData.success(list);
    }
}
